package de.mhus.lib.mandala;

import de.mhus.lib.core.MXml;
import de.mhus.lib.core.base.IgnoreBind;
import de.mhus.lib.core.lang.Prototype;

@Prototype
@IgnoreBind
public abstract class Response {

	private Window window;
	
	public Response(Window window) {
		this.window = window;
	}
	
	public Window getWindow() {
		return window;
	}
	
	public void containerEnter(Sphere component, Object ... infos) {
		
	}

	public void containerLeave() {
		
	}

	public void println() {
		println("");
	}
	
	public abstract void println(String text);
	
	public void singleTag(String name, String clazz, TagAttributes item, String ... attributes) {
		startTag(name, clazz, true, getWindow().getUi().isTextTag(name), item, attributes);
	}
	
	public void startTag(String name, String clazz, TagAttributes item, String ... attributes) {
		startTag(name, clazz, false, getWindow().getUi().isTextTag(name), item, attributes);
	}

	public abstract void startTag(String name, String clazz, boolean single, boolean inline,TagAttributes item, String ... attributes);
	
	public void endTag(String name) {
		endTag(name, getWindow().getUi().isTextTag(name));
	}

	public abstract void endTag(String name, boolean inline);

	public abstract void print(String text);

	public abstract void registerElement(Element value);

	public void printEncoded(String label) {
		print(MXml.encode(label));
	}

	public void lineText(String label) {
		println(MXml.encode(label));
	}
	
	public abstract void renderAttributes();
	
}
